import 'package:flutter/material.dart';
import 'package:online_study/theme/colors.dart';
import 'package:online_study/theme/size.dart';

//课程评论
class CommentItemPage extends StatefulWidget {
  @override
  _CommentItemPageState createState() => _CommentItemPageState();
}

class _CommentItemPageState extends State<CommentItemPage> {
  bool hasRely = true;

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.symmetric(
          vertical: ThemeSize.height12, horizontal: ThemeSize.width19),
      color: ThemeColor.colorWhite,
      child: Column(
        children: [
          _buildComment(),
          _buildReply(),
        ],
      ),
    );
  }

  Widget _buildComment() {
    return Row(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Container(
          margin: EdgeInsets.only(right: ThemeSize.width9),
          height: ThemeSize.height36,
          width: ThemeSize.height36,
          decoration: BoxDecoration(
              shape: BoxShape.circle,
              image: DecorationImage(
                  image: NetworkImage(
                      "https://flutter.github.io/assets-for-api-docs/assets/widgets/owl-2.jpg"),
                  fit: BoxFit.cover)),
        ),
        Expanded(
            child: Column(
          children: [
            Row(
              children: [
                Text("朱亚文",
                    style: TextStyle(
                        fontSize: ThemeSize.sp13,
                        color: ThemeColor.color333333,
                        fontWeight: FontWeight.bold)),
                Container(
                  padding: EdgeInsets.only(left: ThemeSize.width19),
                  child: Text("2021-09-08 12:09",
                      style: TextStyle(
                          fontSize: ThemeSize.sp11,
                          color: ThemeColor.color808080)),
                )
              ],
            ),
            Container(
              padding: EdgeInsets.only(top: ThemeSize.height6),
              child: Text("不错，全是干货！老师讲得不错，幽默风趣，很吸引人，内容对我很有帮助！！！",
                  style: TextStyle(
                      fontSize: ThemeSize.sp13, color: ThemeColor.color333333)),
            )
          ],
        ))
      ],
    );
  }

  Widget _buildReply() {
    if (hasRely) {
      return Container(
        padding:
            EdgeInsets.only(left: ThemeSize.width45, top: ThemeSize.height12),
        child: Row(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Container(
              height: ThemeSize.height26,
              width: ThemeSize.height26,
              margin: EdgeInsets.only(right: ThemeSize.width9),
              decoration: BoxDecoration(
                  shape: BoxShape.circle,
                  image: DecorationImage(
                      image: NetworkImage(
                          "https://flutter.github.io/assets-for-api-docs/assets/widgets/owl-2.jpg"),
                      fit: BoxFit.cover)),
            ),
            Expanded(
                child: Column(
              children: [
                Row(
                  children: [
                    Text("管理员回复朱亚文",
                        style: TextStyle(
                            fontSize: ThemeSize.sp13,
                            color: ThemeColor.color333333,
                            fontWeight: FontWeight.bold)),
                    Container(
                      padding: EdgeInsets.only(left: ThemeSize.width19),
                      child: Text("2021-09-08 14:09",
                          style: TextStyle(
                              fontSize: ThemeSize.sp11,
                              color: ThemeColor.color808080)),
                    )
                  ],
                ),
                Container(
                  alignment: Alignment.topLeft,
                  padding: EdgeInsets.only(top: ThemeSize.height6),
                  child: Text("有提升是我们的宗旨",
                      style: TextStyle(
                          fontSize: ThemeSize.sp13,
                          color: ThemeColor.color333333)),
                )
              ],
            ))
          ],
        ),
      );
    } else {
      return Container();
    }
  }
}
